﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using System.Data;

namespace logic
{
    public class category
    {
        public static void insert(CategoryEntity cate)
        {
            Category.insert(cate);
        }

        public static void update(CategoryEntity cate)
        {
            Category.update(cate);
        }



        public static void delete(int categoryId)
        {
            Category.delete(categoryId);
        }

        public static CategoryEntity getById(int categoryId)
        {
            return Category.getById(categoryId);
        }

        public static bool isExistShortname(int categoryId, string shortname)
        {
            return Category.isExistShortname(categoryId,shortname);
        }

        public static DataTable listAll()
        {
            return Category.listAll();
        }

        public static DataTable getByParent(int parentId)
        {
            return Category.getByParent(parentId);
        }

        public static DataTable listWithCompanyRange(int companyId)
        {
            return Category.listWithCompanyRange(companyId);
        }

        public static DataSet select(string where, string orderby, int pagesize, int pageindex)
        {
            return DAL.DbHelper.ExecuteDataSetPageSize("*", "category", where, "categoryId", orderby, pagesize, pageindex);
        }

       
        public static DataSet subList(string where, string orderby, int pagesize, int pageindex)
        {
            return DAL.DbHelper.ExecuteDataSetPageSize("*", "vw_Category_subList", where, "categoryId", orderby, pagesize, pageindex);
        }

        public static DataSet listWithCompany(string where, string orderby, int pagesize, int pageindex)
        {
            return DAL.DbHelper.ExecuteDataSetPageSize("*", "vw_CategoryWithCompany", where, "categoryId", orderby, pagesize, pageindex);
        }

        public static DataTable listWithReport(string where)
        {
            return Category.listWithReport(where);
        }

        public static DataTable listWithNewParentByCompany(int companyId)
        {
            return Category.listWithNewParentByCompany(companyId);
        }
        public static DataSet listWithCollect(string where, string orderby, int pagesize, int pageindex)
        {
            return DAL.DbHelper.ExecuteDataSetPageSize("*", "vw_Category_listWithCollect", where, "parentId", orderby, pagesize, pageindex);
        }

        public static DataTable listWithParent()
        {
            return Category.listWithParent();
        }
        public static DataTable listWithPurchaseRoot(int adminId)
        {
            return Category.listWithPurchaseRoot(adminId);
        }
        public static DataTable listWithPurchaseSub(int adminId, int parentCategoryId)
        {
            return Category.listWithPurchaseSub(adminId, parentCategoryId);
        }
        public static DataSet listWithPurchase(string where, string orderby, int pagesize, int pageindex)
        {
            return DAL.DbHelper.ExecuteDataSetPageSize("*", "vw_purchaseChargeSeller_list", where, "categoryId", orderby, pagesize, pageindex);
        }
    }
}
